package lab;

import game.Maze;
import game.Player;
import game.Room.Direction;

import java.util.ArrayList;
import java.util.List;


public class Main {

   public static void main(String[] args) {
      //creates maze
      Maze maze = new Maze("A4", "D2");
      maze.getEntry().createNorth("A3").createNorth("A2").createEast("B2").createEast("C2").createNorth("C1").createEast("D1").createSouth("D2").setExit(true);
      maze.getEntry().getNorth().getNorth().getEast().createNorth("B2").createWest("A1");
      maze.getEntry().getNorth().createEast("B3").createSouth("B4").createEast("C4").createNorth("C3").createEast("D3").createSouth("D4");
      
      //creates test path
      List<Character> path = new ArrayList<Character>();
      path.add('N');
      path.add('E');
      path.add('S');
      System.out.println("Validate path >> " + maze.getEntry().validatePath(path)); //on olemas
      System.out.println("Get room from path >> " + maze.getEntry().get(path)); //on olemas
      path.add('S');
      System.out.println("Validate path >> " + maze.getEntry().validatePath(path)); //ei ole olemas
      System.out.println("Get room from path >> " + maze.getEntry().get(path)); //ei ole olemas
      
      //creates players
      Player p1 = new Player("Bilbo", maze.getEntry());
      Player p2 = new Player("Gollum", maze.getEntry().getNorth().getNorth().getEast().getNorth());
      
      p1.move(Direction.NORTH);//legaalne
      p1.move(Direction.WEST);//illegaalne
      p2.move(path);//illegaalne
      path = new ArrayList<Character>();
      path.add('N');
      path.add('E');
      path.add('S');
      p1.setRoom(maze.getEntry());
      p1.move(path);//legaalne
      
      System.out.println(maze.getEntry().get(path).getPlayers());//1
      p1.setRoom(maze.getEntry());
      p2.setRoom(maze.getEntry());
      System.out.println(maze.getEntry().getPlayers());//2
      p1.move(Direction.NORTH);
      p1.move(Direction.SOUTH);
      System.out.println(maze.getEntry().getPlayers());//2
      
      System.out.println(maze.getEntry().findPathTo("A4"));//ruum on sama
      System.out.println(maze.getEntry().findPathTo("D2"));//ruum on olemas (kaugel)
      System.out.println(maze.getEntry().findPathTo(":("));//ruumi pole
   }

}
